function [allGPAShape estShape] = GPA(allpreShape)
[a n N] = size(allpreShape);
allGPAShape = allpreShape;%zeros(2,n,N);
%initial estimate shape
estShape = allpreShape(:,:,1);
estShapeOld = zeros(2,n);
while(sum(sum((estShape - estShapeOld).^2))>0.001)
    for i=1:N
        allGPAShape(:,:,i) = rotateToRefShape(allGPAShape(:,:,i), estShape);
    end
    estShapeOld = estShape;
    %Procruste mean shape
    estShape = getProcrusteMeanShape(allGPAShape);
    'one pass finished'
end
% figure;plotAllShape(allGPAShape, N);
% figure; scatter(estShape(1,:),estShape(2,:),'.');